package zero.tech.games.pdk.event;

import zero.tech.core.ZeroContext;
import zero.tech.core.data.SimpleUser;
import zero.tech.core.event.EventCallbackListener;
import zero.tech.core.event.EventType;
import zero.tech.games.common.TUserAccountUtil;
import zero.tech.games.common.WaterMode;
import zero.tech.games.entity.user.TUserAccount;
import zero.tech.games.logic.common.Room;
import zero.tech.games.logic.data.LogicEventType;
import zero.tech.games.pdk.data.PdkConfig;

public class CheckJoinNomalRoomMoney implements EventCallbackListener<Boolean>{

	@Override
	public EventType netEventType() {
		return LogicEventType.CHECK_JOIN_NOMAL_ROOM_NEEDMONEY;
	}

	@Override
	public Boolean notifyEvent(Object... objs) {
		Room room = (Room) objs[0];
		SimpleUser simpleUser = (SimpleUser) objs[1];
		int uid=simpleUser.getUid();
		TUserAccountUtil userAccountUtil=ZeroContext.getInstance(TUserAccountUtil.class);
		TUserAccount userAccount=userAccountUtil.getUserAccount(uid);
		PdkConfig pdkConfig =(PdkConfig) room.getGameConfig();
		int water_mode=pdkConfig.getWater_mode();
		long water_num=pdkConfig.getWater_num();
		if(water_mode==WaterMode.AA) {
			if(userAccount.getDiamond()>=water_num) {
				return true;
			}
		}
		return false;
//		return true;
	}

	@Override
	public boolean asynchronous() {
		return false;
	}

}
